<?php

	function IsSessionStarted()
	{
		return session_status() == PHP_SESSION_ACTIVE;
	}

	if (isset($_COOKIE[session_name()]) ||
			isset($_GET[session_name()]) ||
			isset($_POST[session_name()]) )
	{
		session_set_cookie_params(0);
		session_start();
	
		if ( isset($_GET['logout']) || !isset($_SESSION['loggedIn']))
		{
			session_destroy();
			setcookie(session_name(), "", time() - 36000, '/'); // tell browser to delete cookie
		}
	}
	
	/*
	echo '<pre>';	
	
	echo 'status: ' , session_status() , "\n";
	echo 'name: ' , session_name() , "\n";
	print_r ($_COOKIE);
	echo "\n";
	
	echo '</pre>';
	*/
?>